﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Slaks.Graphs;
using DataInput;
using System.IO;
using Slaks.Graphs.Category;

namespace UI
{
    class ClusteringExperiment : ExperimentItem
    {
        public ClusteringBase ClusteringAlogrithm;

        public ClusteringExperiment(List<Field> fields, ClusteringBase experiment, String algorithmName)
            : base(fields, TaskType.Clustering, algorithmName)
        {
            ClusteringAlogrithm = experiment;
        }

        public override void runExperiment()
        {            
            base.runExperiment();
            ClusteringAlogrithm.SetDynamicValues(Fields);
            measures.SetDynamicValues(Fields);
            for (int iteration = 0; iteration < Iterations; iteration++)
            {
                GraphList [] clusters = ClusteringAlogrithm.Apply(Graphs);
                Dictionary<String, Object> evaluationMeasures = measures.evaluate(clusters, _categoriesFile);
                /*var dunnIndex = Slaks.Graphs.Analysis.ClusteringAnalysis.GetDunnIndex(clusters, DistanceMeasure);
                var randIndex = Slaks.Graphs.Analysis.ClusteringAnalysis.GetRandIndex(clusters, null);
                var mutualInfo = Slaks.Graphs.Analysis.ClusteringAnalysis.GetMutualInformation(clusters, null, CategoryReader.GetCategoryList(), ClusteringAlogrithm.CountGraphs());*/
                SaveResults(iteration, evaluationMeasures);

            }
        }

    }
}
